﻿#pragma once

#include <vector>

#include "common.h"

#include "game_object.h"
#include "box_object.h"



// 枚举类
enum class PlayerState
{
    Standing,
    WalkingLeft,
    WalkingRight,
};

enum class ObjectTexture
{
    Standing,
    Left,
    Right,
    WalkLeft1,
    WalkLeft2,
    WalkRight1,
    WalkRight2,
    PlayerNum,
    Box = PlayerNum,
    Ground,
    Background,
    Num
};

// 状态机类
class StateMachine
{
public:
    PlayerState currentState = PlayerState::Standing;
    int frameCounter = 0;
    int walkFrame = 0;
    size_t currentTextureIndex = 0;

    void update(PlayerState state);
    size_t getCurrentTextureIndex() const;
};

struct KeyMap
{
    unsigned char key_left;
    unsigned char key_right;
    unsigned char key_jump;
};


// 玩家
class PlayerObject : public GameObject
{
public:
    std::vector<SDL_Texture*> textures;
    StateMachine stateMachine;
    KeyMap keyMap;

public:
    PlayerObject(int x, int y, int width, int height, std::vector<SDL_Texture*>& textures, KeyMap keyMap);

    virtual void render(SDL_Renderer* renderer);

    virtual void handleInput(const bool* keystates);
};